#ifndef SYS_IO_H
#define SYS_IO_H

// 从端口读一个字节
static __inline unsigned char
inb (unsigned short int __port)
{
  unsigned char _v;

  __asm__ __volatile__ ("inb %w1,%0":"=a" (_v):"Nd" (__port));
  return _v;
}

// 从端口读两个字节
static __inline unsigned short int
inw (unsigned short int __port)
{
  unsigned short _v;

  __asm__ __volatile__ ("inw %w1,%0":"=a" (_v):"Nd" (__port));
  return _v;
}

// 写入一个字节到端口
static __inline void
outb (unsigned short int __port, unsigned char __value)
{
  __asm__ __volatile__ ("outb %b0,%w1": :"a" (__value), "Nd" (__port));
}

// 写入两个字节到端口
static __inline void
outw (unsigned short int __port, unsigned short int __value)
{
  __asm__ __volatile__ ("outw %w0,%w1": :"a" (__value), "Nd" (__port));

}

#endif
